#include "stdafx.h"
#include "page_layout.h"

//trigger
//////////////////////////////////////////
trigger::trigger(eTriggerType type, con_str_ref cmd)
	:m_TriggerType(type),m_Cmd(cmd)
{
}

trigger::eTriggerType trigger::string_to_trigger_type(con_str_ref trigger_str)
{
	eTriggerType type = SWITCH_PAGE;

	if (trigger_str == "SWITCH_PAGE")
		type = SWITCH_PAGE;
	else if (trigger_str == "SEND_UDP")
		type = SEND_UDP;

	return type;
}


//button
///////////////////////////////////////////
button::button(con_str_ref text/* ="button" */)
	:m_Text(text)
{
}

button::button(con_str_ref normal_pic_name, con_str_ref cover_pic_name)
	:m_NormalPicName(normal_pic_name),m_CoverPicName(cover_pic_name)
{
}

//page
//////////////////////////////////////////
page::page(con_str_ref page_name, con_str_ref bkg_pic_name/* ="" */)
	:m_PageName(page_name),m_BkgPicName(bkg_pic_name)
{
}

//page_layout
page* page_layout::find_page(con_str_ref page_name)
{
	page *pPage = nullptr;

	for (auto iter=m_Pages.rbegin(); iter!=m_Pages.rend(); ++iter)
	{
		if (iter->get_page_name() == page_name)
		{
			pPage = &(*iter);
			break;
		}
	}

	return pPage;
}
